package andris.android.mobilarena.provider;

import java.util.List;

import andris.android.mobilarena.R;
import andris.android.mobilarena.model.Article;
import android.app.Activity;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class BookmarkListAdapter extends BaseAdapter {

	private final List<Article> mArticles;
	private final LayoutInflater mLayoutInflater;
	
	public BookmarkListAdapter(Activity activity, List<Article> articles){
		super();
		mArticles = articles;
		mLayoutInflater = activity.getLayoutInflater();
	}
	
	@Override
	public int getCount() {
		return mArticles.size();
	}

	@Override
	public Object getItem(int position) {
		return mArticles.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView listItem = (TextView) convertView;
		
		if (listItem == null)
			listItem = (TextView) mLayoutInflater.inflate(R.layout.bookmark_list_item, null);
		
		listItem.setText(mArticles.get(position).getTitle());
		listItem.setBackgroundColor(Color.DKGRAY);
		
		return listItem;
	}

}
